<!-- Embed dashboard -->
<cd-loading-panel *ngIf="loading && grafanaExist"
                  i18n>Loading panel data...</cd-loading-panel>

<cd-alert-panel type="info"
                *ngIf="!grafanaExist"
                i18n>Please consult the&nbsp;<cd-doc section="grafana"></cd-doc>&nbsp;on
  how to configure and enable the monitoring functionality.</cd-alert-panel>

<cd-alert-panel type="info"
                *ngIf="!dashboardExist"
                i18n>Grafana Dashboard doesn't exist. Please refer to
  &nbsp;<cd-doc section="grafana"></cd-doc>&nbsp;on how to add dashboards to Grafana.</cd-alert-panel>

<ng-container *ngIf="grafanaExist && dashboardExist">
  <div class="row mb-3">
    <div class="col-lg-5 d-flex">
      <div class="col-md-3 timepicker">
        <label for="timepicker"
               class="mt-2"
               i18n>Grafana Time Picker</label>
      </div>
      <div class="col-sm-4">
        <select id="timepicker"
                name="timepicker"
                class="form-select"
                [(ngModel)]="time"
                (ngModelChange)="onTimepickerChange($event)">
          <option *ngFor="let key of grafanaTimes"
                  [ngValue]="key.value">{{ key.name }}
          </option>
        </select>
      </div>
      <div class="col-sm-1">
        <button class="btn btn-light ms-3"
                i18n-title
                title="Reset Settings"
                (click)="reset()">
          <i [ngClass]="[icons.undo]"></i>
        </button>
      </div>
      <div class="col-sm-1">
        <button class="btn btn-light ms-3"
                i18n-title
                title="Show hidden information"
                (click)="showMessage = !showMessage">
          <i [ngClass]="[icons.infoCircle, icons.large]"></i>
        </button>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col my-2"
         *ngIf="showMessage">
      <cd-alert-panel type="info"
                      class="mb-3"
                      *ngIf="showMessage"
                      dismissible="true"
                      (dismissed)="showMessage = false"
                      i18n>If no embedded Grafana Dashboard appeared below, please follow&nbsp;<a [href]="grafanaSrc"
                      target="_blank"
                      noopener
                      noreferrer>this link </a>&nbsp;to check if Grafana is reachable and there are no HTTPS certificate issues. You may need to reload this page after accepting any Browser certificate exceptions</cd-alert-panel>
    </div>
  </div>

  <div class="row">
    <div class="col">
      <div class="grafana-container">
        <iframe #iframe
                id="iframe"
                [src]="grafanaSrc"
                class="grafana"
                [ngClass]="panelStyle"
                frameborder="0"
                scrolling="no"
                [title]="title"
                i18n-title>
        </iframe>
      </div>
    </div>
  </div>
</ng-container>
